﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

using System.Text;
using System.IO;
using System.Xml;
using BLL;
using DAL;
using Models;
using System.Data;


public partial class cn_member_center_send_message : System.Web.UI.Page
{
    // Fields
    protected DraftBoxManager dbm = new DraftBoxManager();


    // Methods
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Session["user"] == null)
        {
            base.Response.Redirect("/cn/web_login.html?ru=" + HttpContext.Current.Request.Url.PathAndQuery.Replace("aspx", "html"));
        }
    }

    protected StringBuilder SendMessageBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (base.Request.QueryString["id"] != null)
            {
                DataTable draftBoxById = this.dbm.GetDraftBoxById(Convert.ToInt32(base.Request.QueryString["id"]));
                if (draftBoxById.Rows.Count > 0)
                {
                    DataRow row = draftBoxById.Rows[0];
                    builder.AppendLine("<p class=\"radio_input\"><label>收件人：</label><input id=\"radioType0\" type=\"radio\" name=\"radioType\" class=\"radio\" value=\"0\" " + ((row["addressee"].ToString() != "管理员") ? "checked=\"checked\"" : "") + " />其他会员&nbsp;<input id=\"radioType1\" type=\"radio\" class=\"radio\" name=\"radioType\" value=\"1\" " + ((row["addressee"].ToString() == "管理员") ? "checked=\"checked\"" : "") + " />管理员</p>");
                    builder.AppendLine(string.Concat(new object[] { "<p id=\"pAddressee\" style=\"", (row["addressee"].ToString() == "管理员") ? "display:none;" : "display:block;", "\"><label for=\"txtAddressee\">用户名：</label><input type=\"text\" id=\"txtAddressee\" maxlength=\"20\" value=\"", (row["addressee"].ToString() != "管理员") ? row["addressee"] : "", "\" /><span id=\"spAddressee\">*</span></p>" }));
                    builder.AppendLine("<p><label for=\"txtTitle\">标题：</label><input type=\"text\" id=\"txtTitle\" maxlength=\"50\" value=\"" + row["title"] + "\" /><span id=\"spTitle\">*</span></p>");
                    builder.AppendLine("<p><label for=\"txtaContent\">内容：</label><textarea id=\"txtaContent\" cols=\"20\" rows=\"6\">" + row["content"] + "</textarea><span id=\"spContent\">*</span></p>");
                }
                return builder;
            }
            string str = "管理员";
            if (base.Request.QueryString["addressee"] != null)
            {
                str = base.Request.QueryString["addressee"];
            }
            builder.AppendLine("<p class=\"radio_input\"><label>收件人：</label><input id=\"radioType0\" type=\"radio\" name=\"radioType\" class=\"radio\" value=\"0\" " + ((str != "管理员") ? "checked=\"checked\"" : "") + " />其他会员&nbsp;<input id=\"radioType1\" type=\"radio\" class=\"radio\" name=\"radioType\" value=\"1\" " + ((str == "管理员") ? "checked=\"checked\"" : "") + " />管理员</p>");
            builder.AppendLine("<p id=\"pAddressee\" style=\"" + ((str == "管理员") ? "display:none;" : "display:block;") + "\"><label for=\"txtAddressee\">用户名：</label><input type=\"text\" id=\"txtAddressee\" maxlength=\"20\" value=\"" + ((str != "管理员") ? str : "") + "\" /><span id=\"spAddressee\">*</span></p>");
            builder.AppendLine("<p><label for=\"txtTitle\">标题：</label><input type=\"text\" id=\"txtTitle\" maxlength=\"50\" /><span id=\"spTitle\">*</span></p>");
            builder.AppendLine("<p><label for=\"txtaContent\">内容：</label><textarea id=\"txtaContent\" cols=\"20\" rows=\"6\"></textarea><span id=\"spContent\">*</span></p>");
        }
        catch
        {
        }
        return builder;
    }

}